import { ResponseUtilService } from '@app/response-util';
import { Controller, Post, Req, UploadedFile, UseInterceptors } from '@nestjs/common';
import { FileInterceptor } from '@nestjs/platform-express';
import { ReqAttrs } from '../../constant';
import { UploadService } from './upload.service';

@Controller('upload')
export class UploadController {
    constructor(
        private readonly service:UploadService
    ){}

    @Post('icon')
    @UseInterceptors(FileInterceptor('file'))
    async updateInfo(@UploadedFile() file: Express.Multer.File, @Req() req) {

        const r = await this.service.upload(file, req[ReqAttrs.MEMBER_ID])
        return ResponseUtilService.successRes(r)
    }
}
